<!DOCTYPE html>
<html lang="en">
    <head>
        <title></title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>
    <body>
    <script>
        // 得到一个新的数组.数组的每一项都是callback的返回值
        // array.map(callback,[thisObject])
        // array.map(function(value,index,array){})


        var data = [1,2,3,4];
        var arrayOfSquares = data.map(item=>{
            return item*item;
        })
        alert(arrayOfSquares)

        var users = [
            {name: "张含韵", "email": "zhang@email.com"},
            {name: "江一燕",   "email": "jiang@email.com"},
            {name: "李小璐",  "email": "li@email.com"}
        ];

        var emails = users.map(function (user) { return user.email; });

        console.log(emails.join(", ")); // zhang@email.com, jiang@email.com, li@email.com
    </script>
    </body>
</html>